<?php
/**
 * Created by PhpStorm.
 * User: mojie126
 * Date: 2017/7/6 0006
 * Time: 下午 13:42
 */

namespace app\common;


class download
{
	static function downloadFile($file, $filename)
	{
		$mime = 'application/force-download';
		header('Pragma: public');
		header('Expires: 0');
		header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
		header('Cache-Control: private', FALSE);
		header('Content-Type: ' . $mime);
		header('Content-Disposition: attachment; filename="' . basename($filename) . '"');
		header('Content-Transfer-Encoding: binary');
		header('Connection: close');
		readfile($file);
		exit();
	}
}